/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package co.com.javeriana.aes.oms.ejb.orders.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import javax.naming.NamingException;

/**
 *
 * @author Juan
 */
public class TopOpenOrdersDAO extends GenericDAO {

     /**
     * Metodo para generar la consulta.
     */
    public List<Integer> getTopOpenOrders() {
        Connection cnn = null;
        Statement st = null;
        ResultSet rs = null;
        List<Integer> products = new ArrayList<Integer>();
        
       String sql = "SELECT ORDID FROM ORDERS WHERE  STATUS <> 'CANCELADA' AND ROWNUM < 20  ORDER BY ORDERDATE DESC";
        try {
            cnn = getConnection();
        } catch (NamingException ne) {
            ne.printStackTrace();
        }
        try {
            st = cnn.createStatement();
            rs = st.executeQuery(sql);
            while (rs.next()) {
                String num = rs.getString("ORDID");
                int entero = Integer.parseInt(num);
                products.add(entero);
            }
        } catch (SQLException sqle) {
            sqle.printStackTrace();
        }
        return products;
    }
    
    
}
